#!/usr/bin/env node
const { getDirList } = require("./utils");
const fs = require("fs");
let options = require("./example.comfig.json");
for (let i = process.argv.length - 1; i >= 2; --i) {
  let arg = process.argv[i];
  if (arg.indexOf("--limitDirs=") > -1) {
    let limitArr = arg.substring(12);
    options.limitDirs.push(limitArr);
    process.argv.splice(i, 1);
  } else if (arg.indexOf("--input=") > -1) {
    options.input = arg.substring(8);
    process.argv.splice(i, 1);
  } else if (arg.indexOf("--output=") > -1) {
    options.output = arg.substring(9);
    process.argv.splice(i, 1);
  }
}
console.log(options);
let content;
try {
  content = getDirList(options);
} catch (e) {
  console.log(e);
}
fs.writeFileSync(options.output, content);
